package lumis.portal.channel.serialization;

import java.util.ArrayList;
import java.util.List;

import lumis.portal.channel.template.serialization.ChannelTemplateLinkSerializableConfig;
import lumis.portal.css.serialization.CssSerializableConfig;
import lumis.portal.group.serialization.GroupSerializableConfig;
import lumis.portal.metatag.MetaTagConfig;
import lumis.portal.page.serialization.PageSerializableConfig;
import lumis.portal.serviceinstance.serialization.ServiceInstanceSerializableConfig;
import lumis.portal.user.serialization.UserSerializableConfig;
import lumis.util.security.acl.serialization.AccessControlListSerializableConfig;

/**
 * Serializable value object for Channel structure properties
 *
 * @version $Revision: 9324 $ $Date: 2008-05-20 10:06:04 -0300 (Tue, 20 May 2008) $
 * @since 4.0.7
 */
public class ChannelSerializableConfig
{
	private String id;
	private String name;
	private AccessControlListSerializableConfig accessControlList;
	private List<MetaTagConfig> metaTags = new ArrayList<MetaTagConfig>();
	private List<String> csss = new ArrayList<String>();
	private List<ServiceInstanceSerializableConfig> serviceInstances = new ArrayList<ServiceInstanceSerializableConfig>();
	private List<GroupSerializableConfig> groups = new ArrayList<GroupSerializableConfig>();
	private List<UserSerializableConfig> users = new ArrayList<UserSerializableConfig>();
	private List<PageSerializableConfig> pages = new ArrayList<PageSerializableConfig>();
	private List<ChannelTemplateLinkSerializableConfig> channelTemplateLinks = new ArrayList<ChannelTemplateLinkSerializableConfig>();
	private List<ChannelSerializableConfig> channels = new ArrayList<ChannelSerializableConfig>();
	
	public String getId()
	{
		return id;
	}
	public void setId(String id)
	{
		this.id = id;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public AccessControlListSerializableConfig getAccessControlList()
	{
		return accessControlList;
	}
	public void setAccessControlList(AccessControlListSerializableConfig accessControlList)
	{
		this.accessControlList = accessControlList;
	}
	public List<ChannelSerializableConfig> getChannels()
	{
		return channels;
	}
	public List<MetaTagConfig> getMetaTags()
	{
		return metaTags;
	}
	public List<String> getCsss()
	{
		return csss;
	}
	public List<ServiceInstanceSerializableConfig> getServiceInstances()
	{
		return serviceInstances;
	}
	public List<GroupSerializableConfig> getGroups()
	{
		return groups;
	}
	public List<UserSerializableConfig> getUsers()
	{
		return users;
	}
	public List<PageSerializableConfig> getPages()
	{
		return pages;
	}
	public List<ChannelTemplateLinkSerializableConfig> getChannelTemplateLinks()
	{
		return channelTemplateLinks;
	}
	private Object readResolve()
	{
		for (int i = 0; i < csss.size(); i++)
		{
			Object object = csss.get(i);
			if (object instanceof CssSerializableConfig)
				csss.set(i, null);
		}
		
		// for backward compatibility, because LECs without metaTags element 
		// sets metaTags to null during deserialization
		if (metaTags == null)
			metaTags = new ArrayList<MetaTagConfig>();
		
		return this;
	}
}
